﻿using System;
using System.Collections.Generic;

namespace Songhay.Silverlight.ApplicationLoader.Models
{
    /// <summary>
    /// The information needed
    /// to load the initial payload.
    /// </summary>
    public class LoaderInfo
    {
        public LoaderInfo(IDictionary<string, string> initializationParameters)
        {
            if(initializationParameters == null)
                throw new ArgumentNullException("initializationParameters",
                    "The Silverlight Host does not contain initialization parameters.");

            if(!initializationParameters.ContainsKey("LoaderInfoXapPath") ||
                !initializationParameters.ContainsKey("LoaderInfoXapAssemblyName") ||
                !initializationParameters.ContainsKey("LoaderInfoXapAssemblyCompositionHost"))
                throw new Exception("The Silverlight Host does not contain initialization parameters for the Application Loader.");

            this.XapAssemblyName = initializationParameters["LoaderInfoXapAssemblyName"];
            this.XapAssemblyCompositionHost = initializationParameters["LoaderInfoXapAssemblyCompositionHost"];
            this.XapPath = initializationParameters["LoaderInfoXapPath"];
        }

        /// <summary>
        /// Gets or sets the XAP path.
        /// </summary>
        /// <value>The XAP path.</value>
        public string XapPath { get; set; }

        /// <summary>
        /// Gets or sets the name of the XAP assembly.
        /// </summary>
        /// <value>The name of the XAP assembly.</value>
        public string XapAssemblyName { get; set; }

        /// <summary>
        /// Gets or sets the XAP assembly Silverlight Composition Host.
        /// </summary>
        /// <value>The XAP assembly Silverlight Composition Host.</value>
        public string XapAssemblyCompositionHost { get; set; }
    }
}
